Javascript Regular Expression ============================= alert("Hello ".concat("world!")); ==== var str = "The rain in SPAIN stays mainly in the plain"; str.replace(/ain/g, ""); ==== \ A backslash that precedes a special character indicates that the next character is not special. var str = "The rain* in plain"; str.replace(/\*/g, ""); var str = "The rain/ in plain"; str.replace(/\//g, ""); ==== var str = "The rain in plain"; str.replace(/ /g, ""); str.replace(/(.*r)/g, ""); str.replace(/(.*r|pl.*)/g, ""); ==== var todayDate = new Date(); var todayDateStr = todayDate.toUTCString(); todayDateStr = todayDateStr.replace(/(.*, )/g, ""); todayDateStr = todayDateStr.replace(/(2017.*)/g, "17"); todayDateStr.replace(/ /g, "-"); ==== var re = /\w+\s/g; \w Matches any alphanumeric character including the underscore \s Matches a single white space character var str = 'fee fi fo fum'; var myArray = str.match(re); console.log(myArray); ==== var todayDate = new Date(); var todayDateStr = todayDate.toUTCString(); todayDateStr = todayDateStr.replace(/(.*, )/g, ""); todayDateStr = todayDateStr.replace(/(2017.*)/g, "17"); todayDateStr.replace(/ /g, "-"); todayDateStr.concat("world!") "world!".concat(todayDateStr)